<?php
	class EnsembleDeVilles {
		
		var $villes;
		
		function EnsembleDeVilles($id=NULL){
			$this->villes = array();
			$condition = ($id!=NULL)?' WHERE vi_departement = '.$id.' ':'';
			$villes = $GLOBALS['PHPFoxEngine']->database->query("SELECT vi_nom FROM villes".$condition."ORDER BY vi_nom ASC");
			while($ville = mysql_fetch_assoc($villes)){
				$this->villes[$ville['vi_nom']] = $ville['vi_nom'];
			}	
		}
		
		function makeOptions(){
			$select='';
			foreach($this->villes as $key => $value){
				$select .= '<option id="'.$key.'" value="'.$key.'">'.$value.'</option>';	
			}
			return $select;
		}
	}
?>